<!--
	a mobileUser detail !
-->
<h3>添加课程</h3>
<div ng-controller="coursesDetailCtrl" class="panel panel-default" style="overflow: hidden ">
    <div class="col-md-12">
        <form class="form-validate form-horizontal" name="updateForm" ng-submit="submitForm(updateForm.$valid)">
            <!-- START panel-->
            <div class="panel panel-default" style="border: none;">
                <div class="panel-heading">
                </div>
                <div class="panel-body">
                    <fieldset>
                        <div class="col-sm-4 form-inline">
                            <label class="pull-left" style="margin-right:10px;margin-top:7px" for="">{{courseClassificationSelectName}} : </label>
                            <select style="width: 200px;" class="custom-css form-control col-sm-8" ng-model="courseClassificationSelectValue"  name="courseClassificationSelectValue" ng-options="courseClassificationSelectValue._index_ as courseClassificationSelectValue._value_  for courseClassificationSelectValue in courseClassificationType" required></select>
                        </div>
                        <p class="redBorder" ng-if="updateForm.name.$error.required && updateForm.name.$touched">输入不能为空</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4 form-inline">
                            <label class="pull-left" style="margin-right:10px;margin-top:7px" for="">{{classLabelSelectName}} : </label>
                            <select style="width: 200px;" class="custom-css form-control col-sm-8" ng-model="realmListSelectValue"  name="realmListSelectValue" ng-options="realmListSelectValue.realmId as realmListSelectValue.name   for realmListSelectValue in realmList" required></select>
                        </div>
                        <p class="redBorder" ng-if="updateForm.name.$error.required && updateForm.name.$touched">输入不能为空</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4 form-inline">
                            <label class="pull-left" style="margin-right:10px;margin-top:7px" for="">{{signSelectName}} : </label>
                            <select style="width: 200px;" class="custom-css form-control col-sm-8" ng-model="signSelectValue"  name="signSelectValue" ng-options="signSelectValue._index_ as signSelectValue._value_ for signSelectValue in signType" required></select>
                        </div>
                        <p class="redBorder" ng-if="updateForm.name.$error.required && updateForm.name.$touched">输入不能为空</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4 form-inline">
                            <label class="pull-left" style="margin-right:10px;margin-top:7px" for="">计费方式 : </label>
                            <select style="width: 200px;" class="custom-css form-control col-sm-8" ng-model="billingWaySelectValue"  name="billingWaySelectValue" ng-options="billingWaySelectValue._index_ as billingWaySelectValue._value_ for billingWaySelectValue in billingWayType" required></select>
                        </div>
                    </fieldset>
                    <fieldset>
                        <div class="form-inline panel-heading">
                            是否上传小程序
                            <label style="margin:0 20px">
                                <input type="radio" name="optionsRadios"  value="1" ng-click="isTrue1()" ng-model="product.isApplet"  >
                                是
                            </label>
                            <label>
                                <input type="radio" name="optionsRadios"  value="0" ng-click="isTrue1()" ng-model="product.isApplet">
                                否
                            </label>
                        </div>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4">
                            <input ng-maxlength="50" placeholder="标题" ng-model="product.name" name="name" type="text" class="form-control col-sm-4" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.name.$error.required && updateForm.name.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.name.$error.maxlength && updateForm.name.$touched">输入长度不能大于50字节</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-3">
                            <input placeholder="用户手机号" name="phone" ng-model="product.user.phoneNo" ng-change="userChange()" type="text" class="form-control" required>
                        </div>
                        <div class="col-sm-3">
                            <input placeholder="相应用户" ng-disabled="true" name="userName" ng-model="product.user.name" type="text" class="form-control" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.phone.$error.required && updateForm.phone.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.userName.$error.required">没有找到相应用户</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4">
                            <input ng-maxlength="40" placeholder="头衔" name="label" ng-model="product.label" type="text" class="form-control col-sm-4" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.label.$error.required && updateForm.label.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.label.$error.maxlength && updateForm.label.$touched">输入长度不能大于40字节</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-4">
                            <input ng-maxlength="50" placeholder="一句话简介" name="digest" ng-model="product.digest" type="text" class="form-control col-sm-4" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.digest.$error.required && updateForm.digest.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.digest.$error.maxlength && updateForm.digest.$touched">输入长度不能大于50字节</p>
                    </fieldset>
                    <fieldset>
                        <div>
                            <img id="titleImg" style="height: 200px;width: 150px; line-height: 200px;text-align: center" class="img-thumbnail" src="{{product.headImage}}" alt="app课程封面（300*400）">
                        </div>
                        <button id="titleBtn" style="margin-top: 20px;margin-left: 15px;" class="btn btn-primary">修改app封面图片并上传</button>
                    </fieldset>
                    <fieldset>
                        <div>
                            <img id="contImg" style="height: 450px;width: 621px; line-height: 450px;text-align: center" class="img-thumbnail" src="{{product.image}}" alt="app配图（900*635）">
                        </div>
                        <button id="contBtn" style="margin-top: 20px;margin-left: 240px;" class="btn btn-primary">修改app配图并上传</button>
                    </fieldset>
                    <fieldset ng-show="wxShow">
                        <div>
                            <img id="titleImgWx" style="height: 180px;width: 180px; line-height: 200px;text-align: center" class="img-thumbnail" src="{{product.headAppletImageObj}}" alt="小程序课程封面（180*180）">
                        </div>
                        <button id="titleBtnWx" style="margin-top: 20px;margin-left: 15px;" class="btn btn-primary">选择小程序封面图片</button>
                    </fieldset>
                    <fieldset ng-show="wxShow">
                        <div>
                            <img id="contImgWx" style="height: 400px;width: 690px; line-height: 450px;text-align: center" class="img-thumbnail" src="{{product.appletImageObj}}" alt="配图（690*400）">
                        </div>
                        <button id="contBtnWx" style="margin-top: 20px;margin-left: 240px;" class="btn btn-primary">选择小程序配图</button>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-6">
                            <textarea ng-maxlength="4000" placeholder="课程介绍" name="synopsis" ng-model="product.synopsis" class="form-control" required></textarea>
                        </div>
                        <p class="redBorder" ng-if="updateForm.synopsis.$error.required && updateForm.synopsis.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.synopsis.$error.maxlength && updateForm.synopsis.$touched">输入长度不能大于4000字节</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-6">
                            <textarea ng-maxlength="2000" placeholder="适用人群" name="targeTusers" ng-model="product.targeTusers" class="form-control" required></textarea>
                        </div>
                        <p class="redBorder" ng-if="updateForm.targeTusers.$error.required && updateForm.targeTusers.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.targeTusers.$error.maxlength && updateForm.targeTusers.$touched">输入长度不能大于2000字节</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-6">
                            <textarea ng-maxlength="2000" placeholder="作者介绍" name="authorInfo" ng-model="product.authorInfo" class="form-control" required></textarea>
                        </div>
                        <p class="redBorder" ng-if="updateForm.authorInfo.$error.required && updateForm.authorInfo.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.authorInfo.$error.maxlength && updateForm.authorInfo.$touched">输入长度不能大于2000字节</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-2">
                            <input placeholder="金额" name="price" ng-model="product.price" type="text" class="form-control" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.price.$error.required && updateForm.price.$touched">输入不能为空</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-2">
                            <input ng-pattern="/^\d+$/" placeholder="虚拟数" name="basisData" ng-model="product.basisData" type="text" class="form-control" required>
                        </div>
                        <p class="redBorder" ng-if="updateForm.basisData.$error.required && updateForm.basisData.$touched">输入不能为空</p>
                        <p class="redBorder" ng-if="updateForm.basisData.$error.pattern && updateForm.basisData.$touched">输入需为正整数</p>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-2">
                            <span style="margin-top: 8px;display: inline-block; margin-left: 20px;"><input class="pull-left"  type="radio" class="form-control" name="sex" value="1" ng-model="product.status" required><span class="pull-left">上架</span></span>
                            <span style="margin-top: 8px;display: inline-block; margin-left: 20px;"><input class="pull-left"  type="radio" class="form-control" name="sex" value="2" ng-model="product.status" required><span class="pull-left">下架</span></span>
                        </div>
                    </fieldset>
                    <fieldset>
                        <div class="col-sm-2">
                            <span style="margin-top: 8px;display: inline-block; margin-left: 20px;"><input class="pull-left"  type="radio" class="form-control" name="updstatusN" value="1" ng-model="product.updstatus" required><span class="pull-left">完结</span></span>
                            <span style="margin-top: 8px;display: inline-block; margin-left: 20px;"><input class="pull-left"  type="radio" class="form-control" name="updstatusN" value="2" ng-model="product.updstatus" required><span class="pull-left">未完结</span></span>
                        </div>
                    </fieldset>
                    <fieldset class="text-center" ng-disabled="doNext">
                        <button class="btn btn-primary">确认课程修改</button>
                    </fieldset>
                </div>
            </div>
            <!-- END panel-->
        </form>
    </div>
    <div class="col-md-12" ng-class="loading?'whirl standard':'' " style="border-top: 1px solid #CFDBE2;">
        <table class="table table-striped table-condensed">
            <thead>
            <tr>
                <th>序号</th>
                <th style="max-width: 400px">标题</th>
                <th>试听</th>
                <th>状态</th>
                <th>上线</th>
                <th>排序</th>
                <th>置顶</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <!-- repeat begin -->
            <tr ng-repeat="lessonItem in lessonList ">
                <td>{{$index+1}}</td>
                <td class="input-group" style="max-width: 400px">
                    <input ng-disabled="!lessonItem.disa" type="text" class="form-control" ng-model="lessonItem.title">
                    <span class="input-group-btn" ng-if="!lessonItem.disa">
                        <button class="btn btn-warning" type="button" ng-click="lessonItem.disa=true">编辑</button>
                    </span>
                    <span class="input-group-btn" ng-if="lessonItem.disa">
                        <button class="btn btn-success" type="button" ng-click="lessonItem.disa=false;saveLesson(lessonItem.lessonId,lessonItem.title,lessonItem.isPublic,lessonItem.online)">保存</button>
                    </span>
                </td>
                <td><input type="checkbox" ng-checked="lessonItem.isPublic==1?true:false" ng-click="lessonItem.isPublic==1?lessonItem.isPublic=2:lessonItem.isPublic=1;lessonItem.disa=false;saveLesson(lessonItem.lessonId,lessonItem.title,lessonItem.isPublic,lessonItem.online)"></td>
                <td id="c{{lessonItem.lessonId}}"><span ng-if="lessonItem.mp3"><a target="_blank" href="{{lessonItem.mp3}}">点击查看</a></span><span ng-if="!lessonItem.mp3">--</span></td>
                <!-- online begin -->
                <td><input type="checkbox" ng-checked="lessonItem.online==1?true:false" ng-click="lessonItem.online==1?lessonItem.online=2:lessonItem.online=1;lessonItem.disa=false;updLesson(lessonItem.lessonId,lessonItem.title,lessonItem.isPublic,lessonItem.online)"></td>
                <!-- online end -->
                <td>
                    <a ng-disabled="$index==0" tooltip="升序" tooltip-trigger="mouseenter" class="btn btn-xs btn-danger" ng-click="fnSort(lessonItem.lessonId,1,$index,lessonItem.productId)"><i class="fa fa-long-arrow-up"></i></a>
                    <a ng-disabled="$index==lessonList.length-1" tooltip="降序" tooltip-trigger="mouseenter" class="btn btn-xs btn-success" ng-click="fnSort(lessonItem.lessonId,2,$index,lessonItem.productId)"><i class="fa fa-long-arrow-down"></i></a>
                </td>
                <td>
                    <a tooltip="置顶" tooltip-trigger="mouseenter" class="btn btn-xs btn-default"  ng-click="fnToTop(lessonItem.lessonId,lessonItem.productId)"><i class="fa fa-caret-square-o-up"></i></a>
                </td>
                <td>
                    <a id="a{{lessonItem.lessonId}}" class="btn btn-default">选择音频</a><span></span>
                    <a id="b{{lessonItem.lessonId}}" class="btn btn-primary">上传</a><span></span>
                    <a tooltip="删除" tooltip-trigger="mouseenter" class="btn btn-xs btn-danger" ng-click="removeLesson(lessonItem.lessonId,$index)"><i class="icon-trash"></i></a>
                </td>
            </tr>
            <!-- repeat end -->
            </tbody>
        </table>
        <button type="button" ng-click="addLesson()" class="btn btn-labeled btn-success">
               	<span class="btn-label">
               		<i class="fa fa-plus"></i>
               	</span>添加课时
        </button>
    </div>
</div>